﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ETA.IRepository;
using ETA.IService;

namespace ETA.Service
{
    public class RegistrationBasicInfoService : IRegistrationBasicInfoService
    {
        #region 属性

        private IRegistrationBasicInfoRepository _IRegistrationBasicInfoRepository { set; get; }


        #endregion

        #region 构造函数

        public RegistrationBasicInfoService(IRegistrationBasicInfoRepository IRegistrationBasicInfoRepository)
        {
            _IRegistrationBasicInfoRepository = IRegistrationBasicInfoRepository;
        }

        #endregion

        #region IRegistrationBasicInfoService 成员

        public CreateRegistrationBasicInfoResponse CreateRegistrationBasicInfo(CreateRegistrationBasicInfoRequest req)
        {
            var res = new CreateRegistrationBasicInfoResponse();
            try
            {
                if (req != null)
                {
                    res.RegistrationBasicInfo = _IRegistrationBasicInfoRepository.Insert(req.RegistrationBasicInfo);
                    res.Result.IsSuccess = true;
                }
            }
            catch (Exception e)
            {
                res.Result.IsSuccess = false;
                res.Result.ErrMessage = e.Message;
            }
            return res;
        }

        public ModifyRegistrationBasicInfoResponse ModifyRegistrationBasicInfo(ModifyRegistrationBasicInfoRequest req)
        {
            var res = new ModifyRegistrationBasicInfoResponse();
            try
            {
                if (req != null)
                {
                    res.RegistrationBasicInfo = _IRegistrationBasicInfoRepository.Update(req.RegistrationBasicInfo);
                    res.Result.IsSuccess = true;
                }
            }
            catch (Exception e)
            {
                res.Result.IsSuccess = false;
                res.Result.ErrMessage = e.Message;
            }
            return res;
        }

        #endregion
    }
}
